import urllib2,re,sys


h=urllib2.urlopen('http://www.verycd.com/topics/2866957/').read()
def usage():
    print "Usage: genamulecmdscript.py [url contains ed2k link]"
    
def main():
    if len(sys.argv) != 2:
        usage()
        return 1
    url = sys.argv[1]
    h=urllib2.urlopen(url).read()
    for l in re.findall(r'ed2k="(?P<ed2kurl>ed2k://\|file\|.+?)"',h):
        print 'amulecmd -c "add %s"' % l

if __name__=='__main__':
    sys.exit(main())